import core, { closeForeground, setSystemUiVisibility, getWidthPixels, getHeightPixels } from '@auto.pro/core'
import { run } from '@auto.pro/webview'

core({
    // needCap: true,
    needFloaty: true,
    needService: true,
    // needForeground: true,
});

export const webview = run('file://' + files.path('dist/index.html'), {
    // android:fitsSystemWindows="true"    
    // fitsSystemWindows: "true",
    afterLayout() {
        // if (device.sdkInt >= 23) { // SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
        //     setSystemUiVisibility('有状态栏的沉浸式界面')
        // }
        activity.getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);
    },
    chromeClientOption: {
        onConsoleMessage: function (msg) {
            console.log(msg.message());
        }
    }
});
webview.webviewObject.clearCache(true);
// webview.webviewObject.getSettings().setCacheMode(android.webkit.WebSettings.LOAD_NO_CACHE);

// 监听退出事件，关闭前台服务
events.on('exit', () => {
    closeForeground();
    console.hide();
});
